/**
 * Created with IntelliJ IDEA.
 * User: LuckSuper
 * Date: 12-7-25
 * Time: 下午8:22
 * To change this template use File | Settings | File Templates.
 */

import com.bmc.arsys.api.*;

import java.io.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class Entrance {

    public static void main(String[] args) {
        ARServerUser server = new ARServerUser();
        server.setServer("10.188.238.23");
        server.setUser("Demo");
        server.setPassword("asb#1234");
        try {
            server.login();
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\Data.txt")));
            String data = null;
            while ((data = br.readLine()) != null) {
                String[] arrs = data.split(",");
                String item1 = arrs[0].trim();
                String item2 = arrs[1].trim();
                String item3 = arrs[2].trim();
                Entry e = new Entry();
                e.put(536870913, new Value(item1));
                e.put(536870914, new Value(item2));
                e.put(536870916, new Value(item3));
                server.createEntry("YF_CHG:ChangeForSort", e);
            }
            server.logout();
//            String x = server.getLastStatus().toString();
//            Entry e = new Entry();
//            e.put(2, new Value(args[0]));
//            e.put(8, new Value(args[1]));
//            server.createEntry("Hello", e);
//            int[] kinds = {Constants.ARCON_GUIDE};
//            ArrayList<String> listResult=new ArrayList<String>();
//            List<String> listGuide = server.getListContainer(0, kinds, false, null, null);
//            List<String> listGuideTrue = server.getListContainer(0, kinds, true, null, null);
//            listGuide.addAll(listGuideTrue);
//            for (String item : listGuide) {
//                Container container = server.getContainer(item);
//                List<Reference> references = container.getReferences();
//                for (Reference r : references) {
//                    if (r.getReferenceType() == ReferenceType.ARREF_ENTRYPOINT_ORDER
//                            || r.getReferenceType() == ReferenceType.ARREF_ENTRYPOINT_START_ACTLINK) {
//                        //System.out.println(item);
//                        if(!listResult.contains(item))
//                        {
//                           listResult.add(item+r.getLabel());
//                        }
//                    }
//                }
//            }
//            List<String> forms = server.getListForm();
//            for (String item : forms) {
//                Form form = server.getForm(item);
//                ObjectPropertyMap objectPropertyMap = form.getProperties();
//                Value v1 = objectPropertyMap.get(new Integer(90005));
//                Value v2 = objectPropertyMap.get(new Integer(90006));
//                int i1 = v1 == null ? 0 : v1.getIntValue();
//                int i2 = v2 == null ? 0 : v2.getIntValue();
//                if (i1 > 0 || i2 > 0) {
//                    if(!listResult.contains(item))
//                    {
//                        listResult.add(item+"  "+i1+"  "+i2);
//                    }
//                }
//            }
//            //server.getlist
//            for (String item:listResult)
//            {
//                System.out.println(item);
//            }
//
//            System.out.println(x);
        } catch (ARException e) {
            //server.getListContainer(0,)
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (FileNotFoundException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}
